﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GraphicsFramework.Drawing.SizingHandles
{
    class SizingNode : GraphicBase
    {

        public SizingNode()
            : base(Enum.EnumDrawingType.POLYGON, "Draw Rectangle", Enum.EnumMouseClicks.TWO)
        {
            properties.FillColor = new Property.ColorProperty(0, 0, 0);
        }

        public SizingNode(float x1, float y1, float x2, float y2)
            : base(Enum.EnumDrawingType.POLYGON, "Draw Rectangle", Enum.EnumMouseClicks.TWO)
        {
            properties.FillColor = new Property.ColorProperty(0, 0, 0);
            Initialize(x1, y1, x2, y2);
        }

        private void Initialize(float x1, float y1, float x2, float y2)
        {
            if (x1 > x2)
            {
                float temp = x1;
                x1 = x2;
                x2 = temp;
            }

            if (y1 > y2)
            {
                float temp = y1;
                y1 = y2;
                y2 = temp;
            }

            points = new List<Entity.Point2F>();

            points.Add(new Entity.Point2F(x1, y1));
            points.Add(new Entity.Point2F(x1, y2));
            points.Add(new Entity.Point2F(x2, y2));
            points.Add(new Entity.Point2F(x2, y1));
        }
    }
}
